package com.chinaisafe.user.vo.request;

import com.chinaisafe.base.common.vo.request.PageReqVo;
import com.chinaisafe.base.common.validated.AddGroup;
import com.chinaisafe.base.common.validated.QueryGroup;
import com.chinaisafe.base.common.validated.UpdateGroup;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;
import com.chinaisafe.user.entity.SysTenantApp;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;

/**
 * SysTenantAppReqVO
 * Description：租户和应用请求值对象
 *
 * @author tby
 * @date  2024-07-12 10:04:27
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@Schema(name = "SysTenantAppReqVO", description = "租户和应用请求值对象")
public class SysTenantAppReqVO extends PageReqVo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键id")
    @NotNull(groups = UpdateGroup.class, message = "应用_id不能为空" )
    private Long id;


    @Schema(description = "应用端,WEB:web端应用,APP:app端应用,MINI_APP:小程序")
    private String clientType;

    @Schema(description = "乐观锁版本")
    private Integer version;

    @Schema(description = "应用_id")
    @NotNull(groups = UpdateGroup.class, message = "应用_id不能为空" )
    private Long sysAppId;

    @Schema(description = "别名")
    private String alias;

    private String name;

    @Schema(description = "租期")
    private LocalDate tenancyDate;

    @Schema(description = "排序")
    private Integer seq;

    @Schema(description = "是否上架")
    private Boolean shelf;

    @Schema(description = "是否集成")
    private Boolean integration;


    private String tenancyCode;




    /**
     * 将请求值对象装换为实体
     * @return SysTenantApp
     * @author tby
     * @date 2024-07-12 10:04:27
     */
    public SysTenantApp convertToEntity() {
        SysTenantApp entity = new SysTenantApp();
        entity.setId(this.id);
        entity.setVersion(this.version);
        // 给实体对应的字段赋值 可根据实际业务删减
        entity.setSysAppId(this.sysAppId);
        entity.setAlias(this.alias);
        entity.setTenancyDate(this.tenancyDate);
        entity.setSeq(this.seq);
        return entity;
    }
}
